﻿
using System;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EnterpriseServices.Service
{
    public partial class GroupProxy
    {
        #region IGroupManager Members

        /// <summary>
        /// Creates the parent group.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        /// <param name="groupType">Type of the group.</param>
        public void CreateParentGroup(string userName, string group, GroupType groupType)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.CreateParentGroup(userName, group, groupType);
        }

        /// <summary>
        /// Creates the sub group.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="parentGroup">The parent group.</param>
        /// <param name="group">The group.</param>
        public void CreateSubGroup(string userName, string parentGroup, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.CreateSubGroup(userName, parentGroup, group);
        }

        /// <summary>
        /// Deletes the group.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void DeleteGroup(string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.DeleteGroup(userName, group);
        }

        /// <summary>
        /// Gets the groups for user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        public string[] GetGroupsForUser(string userName)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.GetGroupsForUser( userName);
        }

        /// <summary>
        /// Gets the owners in group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public string[] GetOwnersInGroup(string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.GetOwnersInGroup(group);
        }

        /// <summary>
        /// Gets the contacts in group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public string[] GetContactsInGroup(string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.GetContactsInGroup(group);
        }

        /// <summary>
        /// Gets the direct members in group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public string[] GetDirectMembersInGroup(string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.GetDirectMembersInGroup(group);
        }

        /// <summary>
        /// Gets all eventual members in group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public string[] GetAllEventualMembersInGroup(string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.GetAllEventualMembersInGroup(group);
        }

        /// <summary>
        /// Gets the sub groups in group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public string[] GetSubGroupsInGroup(string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.GetSubGroupsInGroup(group);
        }

        /// <summary>
        /// Adds the contact to group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void AddContactToGroup(string ownerUserName, string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.AddContactToGroup(ownerUserName, userName, group);
        }

        /// <summary>
        /// Adds the owner to group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void AddOwnerToGroup(string ownerUserName, string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.AddOwnerToGroup(ownerUserName, userName, group);
        }

        /// <summary>
        /// Adds the direct member to group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void AddDirectMemberToGroup(string ownerUserName, string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.AddDirectMemberToGroup(ownerUserName, userName, group);
        }

        /// <summary>
        /// Removes the contact from group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void RemoveContactFromGroup(string ownerUserName, string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.RemoveContactFromGroup(ownerUserName, userName, group);
        }

        /// <summary>
        /// Removes the owner from group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void RemoveOwnerFromGroup(string ownerUserName, string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.RemoveOwnerFromGroup(ownerUserName, userName, group);
        }

        /// <summary>
        /// Removes the direct member from group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void RemoveDirectMemberFromGroup(string ownerUserName, string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.RemoveDirectMemberFromGroup(ownerUserName, userName, group);
        }

        /// <summary>
        /// Removes the user from groups.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        public void RemoveUserFromGroups(string ownerUserName, string userName, string[] group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            proxy.RemoveUserFromGroups(ownerUserName, userName, group);
        }

        /// <summary>
        /// Determines whether [is group enabled] [the specified group].
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [is group enabled] [the specified group]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsGroupEnabled(string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.IsGroupEnabled(group);
        }

        /// <summary>
        /// Groups the exists.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        public bool GroupExists(string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.GroupExists(group);
        }

        /// <summary>
        /// Determines whether [is user group owner] [the specified user name].
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [is user group owner] [the specified user name]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsUserGroupOwner(string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.IsUserGroupOwner(userName, group);
        }

        /// <summary>
        /// Determines whether [is user group contact] [the specified user name].
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [is user group contact] [the specified user name]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsUserGroupContact(string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.IsUserGroupContact(userName, group);
        }

        /// <summary>
        /// Determines whether [is user direct member] [the specified user name].
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [is user direct member] [the specified user name]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsUserDirectMember(string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.IsUserDirectMember(userName, group);
        }

        /// <summary>
        /// Determines whether [is user eventual member] [the specified user name].
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [is user eventual member] [the specified user name]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsUserEventualMember(string userName, string group)
        {
            IGroupManager proxy = new ChannelFactory<IGroupManager>().CreateChannel();
            return proxy.IsUserEventualMember(userName, group);
        }

        #endregion
    }
}
